package com.color.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.color.dao.IOpenNoDao;
import com.color.entity.OpenNo;

@Repository("openNoDao")
public class OpenNoDaoImpl extends HibernateBaseDao<OpenNo> implements IOpenNoDao {

	/**
	 * 删除
	 */
	public int Delete(OpenNo open) {
		return delete(open);
	}
	
	/**
	 * 删除
	 */
	public void Delete(List<OpenNo> opens) {
		if(opens != null){
			for(OpenNo open : opens){
				delete(open);
			}
		}
	}
	
	/**
	 * 新增、修改
	 */
	public int Save(OpenNo open) {
		return save(open);
	}
	
	/**
	 * 新增、修改
	 */
	public void Save(List<OpenNo> opens) {
		if(opens != null){
			for(OpenNo open : opens){
				save(open);
			}
		}
	}
	
	/**
	 * 总记录数
	 */
	public int getCountList() {
		StringBuffer strHql = new StringBuffer();
		strHql.append(" select count(sId) as count from OpenNo ");
		return openCountByHql(strHql.toString());
	}

	/**
	 * 分页记录
	 */
	public List<OpenNo> getPageList(int page, int size) {
		StringBuffer strHql = new StringBuffer();
		strHql.append(" from OpenNo order by sNo desc,sId desc");
		List<OpenNo> list = openHqlPage(strHql.toString(),page,size);
		return list;
	}
	
	/**
	 * 获取开奖记录
	 */
	public OpenNo getOpenBysNo(String sNo) {
		StringBuffer strHql = new StringBuffer();
		strHql.append(" from OpenNo where sNo = ? ");
		return openHqlOne(strHql.toString(),new Object[]{sNo});
	}

}
